package ext.db;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SqlHelper {
	
	//列名
	private List<String> columns = new ArrayList<String>();
	//参数
	private List<Object> params = new ArrayList<Object>();
	//sql
	private StringBuilder sqlBulider = new StringBuilder();
	
	private boolean useConditions = false;
	
	public SqlHelper add(String name,Object value){
		columns.add(name);
		params.add(value);
		return this;
	}
	
	public Object[] getParamArray(){
		return this.params.toArray();
	}
	
	public void addParam(Object param){
		this.params.add(param);
	}
	
	public void addColumn(String name){
		this.columns.add(name);
	}
	
	public SqlHelper append(String sql,Object...params){
		sqlBulider.append(sql);
		this.params.addAll(Arrays.asList(params));
		return this;
	}
	
	public SqlHelper() {
		
	}
	
	public List<String> getColumns() {
		return columns;
	}
	public void setColumns(List<String> columns) {
		this.columns = columns;
	}
	public List<Object> getParams() {
		return params;
	}
	public void setParams(List<Object> params) {
		this.params = params;
	}
	public StringBuilder getSqlBulider() {
		return sqlBulider;
	}
	public void setSqlBulider(StringBuilder sqlBulider) {
		this.sqlBulider = sqlBulider;
	}

	public boolean isUseConditions() {
		return useConditions;
	}

	public void setUseConditions(boolean useConditions) {
		this.useConditions = useConditions;
	}
	
	
	
}
